package com.undefined.export.controller;

import com.undefined.export.entity.ExportTemplate;
import com.undefined.export.request.ExportTaskRequest;
import com.undefined.export.request.ExportTemplateRequest;
import com.undefined.export.result.CommonResult;
import com.undefined.export.service.ExportTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
public class ExportTaskController {

    @Autowired
    private ExportTaskService exportTaskService;

    /**
     * 导出模板创建
     *
     * @param exportTemplateRequest
     * @return
     */
    @PostMapping("/createExportTemplate")
    @ResponseBody
    public CommonResult createExportTemplate(@RequestBody ExportTemplateRequest exportTemplateRequest) {
        exportTaskService.createExportTemplate(exportTemplateRequest);
        return new CommonResult();
    }

    @PostMapping("/createTask")
    public CommonResult<Long> createTask(@RequestBody ExportTaskRequest exportTaskRequest) {
        Long id = exportTaskService.createTask(exportTaskRequest);
        return new CommonResult<>(id);
    }

}
